<?php

namespace app\api\model\wanlshop;

use think\Model;
use think\Request;
use traits\model\SoftDelete;

class GoodsSku extends Model
{

    use SoftDelete;

    // 表名
    protected $name = 'wanlshop_goods_sku';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';
	
	
	// getDifferenceAttr
	public function getDifferenceAttr($value)
	{	
		return $value ? explode(',', $value) : [];
	}

    // getImagesAttr
    public function getImageAttr($value, $data){
        $request = Request::instance();
        if (substr($request->url(), 0, 4) == '/api' && strpos($request->url(),'addOrder') == false) {
            return cdnurl($value, true);
        }
        return $value;
    }
}
